use dataset_county, clear

gen dturnout = turnout2012 - turnout2000
gen ddemvoteshare = demvoteshare2012 - demvoteshare2000
gen dcompetition = competition2012 - competition2000
gen dmedianincome = medianincome2010 - medianincome2000
gen dunemployment = unemployment2012 - unemployment2000
gen dgini = gini2012 - gini2000
gen dnetmig = netmig2012 - netmig2000
gen ddeathrate = deathrate2012 - deathrate2000
gen dcollege = college2010 - college2000

label variable dturnout "Turnout"
label variable ddemvoteshare "Dem. Vote"
label variable dcompetition "Competition"
label variable dmedianincome "Income"
label variable dunemployment "Unemployment"
label variable dgini "Gini"
label variable dnetmig "Migration"
label variable ddeathrate "Drug Deaths"
label variable dcollege "College"

label variable frack "Fracking"

eststo clear

foreach x in turnout demvoteshare competition medianincome gini ///
	unemployment college netmig deathrate {

	eststo: reg d`x' frack, robust

}


#delimit;

esttab using "_output/table4a.tex",
	replace
	booktabs
	cells(b(fmt(2) star) se(par))
	compress
	label
	gap
	collabels(none)
	stats(
		N
		,
			label("Observations")
			fmt(%20.0fc)
	)
	star(+ 0.1 * 0.05 ** 0.01 *** 0.001)	
	;
	
#delimit cr

keep if highf == 1

eststo clear

foreach x in turnout demvoteshare competition medianincome gini ///
	unemployment college netmig deathrate {

	eststo: reg d`x' frack, robust

}


#delimit;

esttab using "_output/table4b.tex",
	replace
	booktabs
	cells(b(fmt(2) star) se(par))
	compress
	label
	gap
	collabels(none)
	stats(
		N
		,
			label("Observations")
			fmt(%20.0fc)
	)
	star(+ 0.1 * 0.05 ** 0.01 *** 0.001)
	;
	
#delimit cr
